import {get, post} from "@/sdk/http/http";
// 自定义api地址
const baseURL = "/api";
export function api({path, method}, params = {}) {
    return new Promise((resolve, reject) => {
        if (method === "get") {
            get(baseURL + path, params)
                .then(
                    response => {
                        resolve(response);
                    },
                    error => {
                        reject(error);
                    }
                )
                .catch(err => {
                    reject(err);
                });
        } else {
            // 默认使用post
            post(baseURL + path, params)
                .then(
                    response => {
                        resolve(response);
                    },
                    error => {
                        reject(error);
                    }
                )
                .catch(err => {
                    reject(err);
                });
        }
    });
}
